package com.etc.medical.client;

import com.etc.common.utils.Result;
import com.etc.drug.entity.Drug;
import com.etc.medical.breaker.DrugBreak;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Date;

@FeignClient(value = "sp-drug", fallback = DrugBreak.class)
public interface DrugClient {

    @RequestMapping("/drug/queryCategory")
    Result queryCategory(@RequestParam("pageNum") Integer pageNum,
                         @RequestParam("pageSize") Integer pageSize);


    @RequestMapping(value = "/drug/insert", method = RequestMethod.POST)
    Result insert(@RequestBody Drug drug);

    @RequestMapping(value = "/drug/update", method = RequestMethod.POST)
     Result update(@RequestBody Drug drug);

    @RequestMapping("/drug/queryByPId")
    Result queryByPId(@RequestParam("prescriptionId") String prescriptionId);

    @RequestMapping(value = "/drug/storage", method = RequestMethod.POST)
    Result storage(@RequestParam("drugId") String drugId, @RequestParam("drugPack") Integer drugPack,
                   @RequestParam("drugValidity") @DateTimeFormat(pattern = "yyyy-MM-dd") Date drugValidity,
                   @RequestParam("storageNum") Integer storageNum,
                   @RequestParam("operatorId") String operatorId);

    @RequestMapping(value = "/drug/outbound", method = RequestMethod.POST)
    Result outbound(@RequestParam("prescriptionId") String prescriptionId,
                    @RequestParam("drugId") String drugId,
                    @RequestParam("drugValidity") @DateTimeFormat(pattern = "yyyy-MM-dd") Date drugValidity,
                    @RequestParam("outboundNum") Integer outBoundDose,
                    @RequestParam("operatorId") String operatorId);

    @RequestMapping("/drug/queryStorage")
    Result queryDrugNum(@RequestParam("pageNum") Integer pageNum,
                        @RequestParam("pageSize") Integer pageSize);

    @RequestMapping(value = "/drug/updateStatue", method = RequestMethod.POST)
    Result updateStatue(@RequestParam("outboundId") String outboundId, @RequestParam("operatorId") String operatorId);
}
